package wyp.lib.java.tools;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public final class WypCalendarTool {

	private WypCalendarTool() {
		super();
	}

	public final static class CalendarParams {
		public int year;
		public int month;
		public int day;
		public int hour;
		public int minute;
		public int second;
	}

	public final static String calendar2String(Calendar __calendar, SimpleDateFormat __format) {
		return WypDateTool.date2String(__calendar.getTime(), __format);
	}

	/**
	 * 
	 * @param __calendar
	 * @return
	 */
	public final static CalendarParams resolveCalendar(Calendar __calendar) {
		CalendarParams __params = new CalendarParams();
		__params.year = __calendar.get(Calendar.YEAR);
		__params.month = __calendar.get(Calendar.MONTH);
		__params.day = __calendar.get(Calendar.DAY_OF_MONTH);
		__params.hour = __calendar.get(Calendar.HOUR_OF_DAY);
		__params.minute = __calendar.get(Calendar.MINUTE);
		__params.second = __calendar.get(Calendar.SECOND);
		return __params;
	}

	/**
	 * 清楚Calendar对象的时、分、秒、分、秒
	 * 
	 * @param __calendar
	 */
	public final static void clearCalendarHMS(Calendar __calendar) {
		__calendar.getTimeInMillis();
		__calendar.set(Calendar.HOUR_OF_DAY, 0);
		__calendar.set(Calendar.MINUTE, 0);
		__calendar.set(Calendar.SECOND, 0);
		__calendar.set(Calendar.MILLISECOND, 0);
		__calendar.getTimeInMillis();
	}

}
